package com.tuozixuan.codedemo.java10;

import java.util.ArrayList;
import java.util.Arrays;

public class VarDemo {

	public static void main(String[] args) {
		var str = "ABC"; // 根据推断为字符串类型
		var longValue = 10L; // 根据10L推断long类型
		var flag = true; // 根据true推断boolean类型
		var list = new ArrayList<String>();// 推断ArrayList<String>
		var stream = list.stream();// 推断Stream<String>

		// var关键字修饰的传统for循环
		var stringList = Arrays.asList("AA", "BB", "CC");
		for (var i = 0; i < stringList.size(); i++) {
		     System.out.println(stringList.get(i));
		}
		
		// var关键字修饰的增强for循环
		for (var localStr : stringList) {
		     System.out.println(localStr);
		}
	}

}
